﻿

'*******************************************************************
' Program: Data Center Visio Rack Tool
' Author: Albert E Edlund
' Date:
'
' Purpose:
'
'
'*******************************************************************

Imports System.Runtime.InteropServices
Imports Microsoft.Office.Interop.Visio


Imports System
Imports System.Collections.Generic
Imports System.Collections.ObjectModel

Imports Microsoft.Practices.EnterpriseLibrary.Common
Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHandling
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging


Imports visRackComponentAttributes.clsDC_RackData

Imports System.Data.OleDb
Imports System.IO
Imports Microsoft.Reporting.WinForms
Imports Microsoft.Office.Interop


Public Class frmCompAttr


#Region " Drawing Constants "



    ' the internal container stencil
    Const masterContainerStencilU As String = ""
    ' our default container
    Const masterContainerNameU As String = "Container 3"
    ' wireframe stencil for list (vertical w/header on top) control
    Const stencilWFControl As String = "wfctrl_u.vss"
    ' wireframe master for vertical list
    Const masterListBox As String = "List box"
    ' wireframe master for vertical list item
    Const masterListBoxItem As String = "List box item"
    ' wireframe stencil for list (vertical w/header on side and horizontal) toolbar 
    Const stencilWFToolbar As String = "wftlbr_u.vss"

    Const masterMenuBar As String = "Menu bar"
    Const masterMenuBarItem As String = "Menu bar item"

    Const masterDropDown As String = "Drop-down menu"
    Const masterDropDownItem As String = "Menu item"

    Const constDefaultContainerHeight As String = "1 in"
    Const constDefaultContainerWidth As String = "2 in"
    ' start .75 from left side of page and the top
    Const constDefaultContainerMargin As String = "0.75 in"




#End Region

#Region " Properties and definitions "


    ' our utilities for visio
    Private _clsVisio As clsVisioSupport

    ' our data source class
    Private _clsData As clsDC_RackData

    ' flag that we are testing with other than
    ' sql server data
    Private blnExcelSource As Boolean


    '********* visio snippet vb.net vis0041vb ******************
    Private _drawingApplication As Microsoft.Office.Interop.Visio.Application
    Public Property drawingApplication() As Microsoft.Office.Interop.Visio.Application
        Get
            Return Me._drawingApplication
        End Get
        Set(ByVal value As Microsoft.Office.Interop.Visio.Application)
            If (value Is Nothing) Then
                Throw New System.ArgumentNullException("ApplicationValueIsNull", _
                    "drawingApplication is Null.")
            End If
            Me._drawingApplication = value
        End Set
    End Property

    '********* visio snippet vb.net vis0043vb ******************
    Private _drawingDocument As Microsoft.Office.Interop.Visio.Document
    Public Property drawingDocument() As Microsoft.Office.Interop.Visio.Document
        Get
            Return Me._drawingDocument
        End Get
        Set(ByVal value As Microsoft.Office.Interop.Visio.Document)
            If (value Is Nothing) Then
                Throw New System.ArgumentNullException("DocumentValueIsNull", _
                    "drawingDocument is Null.")
            End If
            Me._drawingDocument = value
        End Set
    End Property

    '********* visio snippet vb.net vis0045vb ******************
    Private _drawingWindow As Microsoft.Office.Interop.Visio.Window
    Public Property drawingWindow() As Microsoft.Office.Interop.Visio.Window
        Get
            Return Me._drawingWindow
        End Get
        Set(ByVal value As Microsoft.Office.Interop.Visio.Window)
            If (value Is Nothing) Then
                Throw New System.ArgumentNullException("WindowValueIsNull", _
                    "drawingWindow is Null.")
            End If
            Me._drawingWindow = value
        End Set
    End Property

    '********* visio snippet vb.net vis0044vb ******************
    Private _drawingPage As Microsoft.Office.Interop.Visio.Page
    Public Property drawingPage() As Microsoft.Office.Interop.Visio.Page
        Get
            Return Me._drawingPage
        End Get
        Set(ByVal value As Microsoft.Office.Interop.Visio.Page)
            If (value Is Nothing) Then
                Throw New System.ArgumentNullException("PageValueIsNull", _
                    "drawingPage is Null.")
            End If
            Me._drawingPage = value
        End Set
    End Property


    '********* visio snippet vb.net vis0042vb ******************
    Private _drawingControl As AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl
    Public Property drawingControl() As AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl
        Get
            Return Me._drawingControl
        End Get
        Set(ByVal value As AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl)
            Me._drawingControl = value
        End Set
    End Property

    Private m_clsReporting As visRackComponentAttributes.clsDC_RackReporting
    Private Property _clsReporting As visRackComponentAttributes.clsDC_RackReporting
        Get
            Return m_clsReporting
        End Get
        Set(ByVal value As visRackComponentAttributes.clsDC_RackReporting)
            m_clsReporting = value
        End Set
    End Property

    Private _CompName As String
    Public Property compName As String
        Get
            Return Me._CompName
        End Get
        Set(ByVal value As String)
            Me._CompName = value
            Me.lblCompName.Text = _CompName
        End Set
    End Property

    Private _compKey As Int32
    Public Property compKey As Int32
        Get
            Return Me._compKey
        End Get
        Set(ByVal value As Int32)
            Me._compKey = value
            Me.lblCompKey.Text = value.ToString
        End Set
    End Property

    Public m_customstencilpath As String = My.Settings.path_custom_stencils
    Public Property _CustomStencilPath() As String
        Get
            Return Me.m_customstencilpath
        End Get
        Set(ByVal value As String)
            Me.m_customstencilpath = value
        End Set
    End Property

    Public m_customdatapath As String = My.Settings.path_custom_data
    Public Property _CustomDataPath As String
        Get
            Return Me.m_customdatapath
        End Get
        Set(ByVal value As String)
            Me.m_customdatapath = value
        End Set
    End Property


#End Region

#Region " Constructor "



    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        Try


            Me.sblStatusOne.Text = "Uninitialized"

            Me.compKey = 1909
            Me.blnExcelSource = True

            Me.LoadDataToolStripMenuItem1.Enabled = blnExcelSource


            drawingControl = attributesDrawControl
            ' get the environment data from the drawing control
            InitTheDrawingControl()
            ' this will use the mouse action as a menu inside the drawing
            AddHandler drawingWindow.MouseUp, AddressOf mouseUp_EventHandler


            _clsVisio = New clsVisioSupport()
            _clsVisio.drawingApplication = drawingApplication
            _clsVisio.drawingDocument = drawingDocument


            ' create our data cache
            If _clsData Is Nothing Then
                _clsData = New clsDC_RackData
            Else
                _clsData = Nothing
                _clsData = New clsDC_RackData
            End If

            ' keep the data cache in sync with the drawing control
            _clsData.drawingApplication = drawingApplication
            ' make the imported datatables available as datarecordsets within the document for later use by the enduser
            _clsData.drawingDocument = drawingDocument
            ' add the ability to save datarecordsets in the document for this solution
            _clsData._BlnDR = True

            ' now the report viewer control stuff
            '
            attributesReportViewer.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local

            Dim dtTemp As System.Data.DataTable = New System.Data.DataTable
            ' get a copy of the component table
            Try
                dtTemp = _clsData.m_ds.Tables(DC_RackTables.tblComponents.ToString).Copy
            Catch rdTemp As Exception
                Exit Sub
            End Try

            ' clear any existing reporting class
            _clsReporting = Nothing
            ' load the component report
            _clsReporting = New visRackComponentAttributes.clsDC_RackReporting _
                    (Me.attributesReportViewer, _
                    _clsReporting.baseReports.rptComponentsAll, _
                    dtTemp)
            _clsReporting._LocalViewer.RefreshReport()

        Catch rpt As ReportViewerException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(rpt, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If

        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try


    End Sub


    '********* visio snippet vb.net vis0049vb ******************
    ' Properties and Definitions
    Private Const defaultDocumentName As String = "compAttributesDocument"
    Private Const defaultPageName As String = "compAttributesPage"

    Private Sub InitTheDrawingControl()

        Try

            '
            ' get the pointers
            '
            ' make sure the control does not change the pagesizebehavior
            Me.drawingControl.PageSizingBehavior = VisPageSizingBehaviors.visNeverResizePages

            Me.drawingWindow = Me.drawingControl.Window
            Me.drawingWindow.Activate()
            Me.drawingApplication = Me.drawingControl.Window.Application

            Me.drawingDocument = Me.drawingControl.Document
            Dim docSheet As Shape = Me.drawingDocument.DocumentSheet
            docSheet.NameU = defaultDocumentName
            Me.drawingDocument.DiagramServicesEnabled = VisDiagramServices.visServiceVersion140

            Me.drawingPage = Me.drawingControl.Window.Page
            Me.drawingPage.NameU = defaultPageName
            drawingWindow.Page = drawingPage

            Me.drawingApplication.Application.Settings.EnableAutoConnect = False
            Me.drawingApplication.OnDataChangeDelay = -2

            Me.drawingWindow.ShowGrid = False
            Me.drawingWindow.ShowPageTabs = True
            Me.drawingWindow.ShowRulers = False
            Me.drawingWindow.ShowScrollBars = True


        Catch com As COMException
            ' add com exception handler here
            '********* visio snippet vb.net vis0056vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If

        Catch ex As Exception
            ' add exception handler here
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub




#End Region

#Region " Visio Events "

    '
    ' 
    '
    Private Sub mouseUp_EventHandler(ByVal mouseButton As Integer, _
                ByVal buttonState As Integer, _
                ByVal clickLocationX As Double, _
                ByVal clickLocationY As Double, _
                ByRef cancelProcessing As Boolean)

        Const tolerance As Double = 0.0001

        Dim clickedShapes As Microsoft.Office.Interop.Visio.Selection = Nothing
        Dim message As New System.Text.StringBuilder()

        Try

            ' Check if the left mouse mouseButton caused this event
            ' to occur.
            If mouseButton = CInt(Microsoft.Office.Interop.Visio. _
                VisKeyButtonFlags.visMouseLeft) Then

                ' Get the list of shapes at the click location.
                clickedShapes = getMouseClickShapes( _
                    drawingWindow.PageAsObj, clickLocationX, _
                    clickLocationY, tolerance)

                ' Check if any shapes were found.
                If ((Not clickedShapes Is Nothing) And _
                    (clickedShapes.Count = 1)) Then

                    If clickedShapes.Item(1).CellExists("user.attrkey", False) = True Then
                        Dim strAttrCell As String = clickedShapes.Item(1).Cells("user.attrkey").ResultStr("")

                        ' Show the name of shape.
                        message.Append(clickedShapes.Item(1).NameU & _
                            System.Environment.NewLine)

                        ' parse out the shape name
                        ' first string is the record field name
                        ' second string is the record key
                        Dim instance As String = strAttrCell
                        Dim charSeparators() As Char = {"_"c}
                        Dim count As Integer = 2
                        Dim options As StringSplitOptions = StringSplitOptions.None
                        Dim returnValue As String()

                        returnValue = instance.Split(charSeparators, _
                                count, options)

                        'If (drawingWindow.Application.AlertResponse = 0) Then
                        '    System.Windows.Forms.MessageBox.Show(message.ToString())
                        'End If

                        ' based on the field name load the reportviewer
                        loadItemReport(returnValue(0))

                    End If ' cell exists
                End If ' a shape is there
            End If

        Catch com As COMException
            '********* visio snippet vb.net vis0056vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If

        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub

    '
    ' find the shape that was acted on 
    '
    Private Shared Function getMouseClickShapes( _
                ByVal clickedPage As Microsoft.Office.Interop.Visio.Page, _
                ByVal clickedLocationX As Double, _
                ByVal clickedLocationY As Double, _
                ByVal tolerance As Double) _
                As Microsoft.Office.Interop.Visio.Selection

        Dim clickedShapes As Microsoft.Office.Interop.Visio.Selection = Nothing

        Try

            ' Use the SpatialSearch method of the page to get the list
            ' of shapes at the location.
            clickedShapes = clickedPage.SpatialSearch( _
                clickedLocationX, clickedLocationY, _
                CInt(Microsoft.Office.Interop.Visio. _
                VisSpatialRelationCodes.visSpatialContainedIn), _
                tolerance, _
                CInt(Microsoft.Office.Interop.Visio. _
                VisSpatialRelationFlags.visSpatialFrontToBack))


        Catch com As COMException
            '********* visio snippet vb.net vis0056vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If

        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try


        Return clickedShapes

    End Function



#End Region

#Region " Form Events "

    Private Sub frmCompAttributes_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.attributesReportViewer.RefreshReport()
    End Sub


    Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        Me.Close()
    End Sub


    '
    ' load test data from excel
    '
    Private Sub LoadDataToolStripMenuItem1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LoadDataToolStripMenuItem1.Click

        loadTestDictTables()
        loadExcelTestData()

    End Sub

    '
    ' pass in a selected shape's name and prefix and load up an item report
    ' the name prefix is the field name for the key 
    '
    Private Sub loadItemReport(ByVal strNode As String)


        Dim dtWork As System.Data.DataTable = Nothing

        Try


            Dim dtWorkName As String = ""

            _clsReporting._LocalViewer = Me.attributesReportViewer
            _clsReporting._LocalViewer.Reset()
            _clsReporting._LocalViewer.LocalReport.DataSources.Clear()
            _clsReporting._DataSource = "Uninitialized"

            Select Case strNode
                Case "compKey"
                    ' component node
                    _clsReporting.initReports(_clsReporting.baseReports.rptComponentsAll)
                    dtWork = _clsData.m_ds.Tables(DC_RackTables.tblComponents.ToString).Copy
                    dtWorkName = DC_RackTables.tblComponents.ToString
                    Exit Select

                Case ("osKey")
                    ' operating system
                    _clsReporting.initReports(_clsReporting.baseReports.rptOSAll)
                    dtWork = _clsData.m_ds.Tables(DC_RackTables.tblAttrOperatingSystem.ToString).Copy
                    dtWorkName = DC_RackTables.tblAttrOperatingSystem.ToString
                    Exit Select

                Case ("vhKey")
                    ' Virtual Hosts
                    _clsReporting.initReports(_clsReporting.baseReports.rptVHAll)
                    dtWork = _clsData.m_ds.Tables(DC_RackTables.tblAttrVirtualHost.ToString).Copy
                    dtWorkName = DC_RackTables.tblAttrVirtualHost.ToString
                    Exit Select

                Case "appKey"
                    ' applications
                    _clsReporting.initReports(_clsReporting.baseReports.rptApplicationsAll)
                    dtWork = _clsData.m_ds.Tables(DC_RackTables.tblAttrApplication.ToString).Copy
                    dtWorkName = DC_RackTables.tblAttrApplication.ToString
                    Exit Select

                Case "physProcKey"
                    ' proccessor records
                    _clsReporting.initReports(_clsReporting.baseReports.rptAttrProcessorsAll)
                    dtWork = _clsData.m_ds.Tables(DC_RackTables.tblAttrProcessor.ToString).Copy
                    dtWorkName = DC_RackTables.tblAttrProcessor.ToString
                    Exit Select

                Case "logicalDiskKey"
                    ' logical disk
                    _clsReporting.initReports(_clsReporting.baseReports.rptDiskLogicalsAll)
                    dtWork = _clsData.m_ds.Tables(DC_RackTables.tblAttrDiskLogical.ToString).Copy
                    dtWorkName = DC_RackTables.tblAttrDiskLogical.ToString
                    Exit Select

                Case "physDiskKey"
                    ' physcial disk
                    _clsReporting.initReports(_clsReporting.baseReports.rptDiskPhysicalsAll)
                    dtWork = _clsData.m_ds.Tables(DC_RackTables.tblAttrDiskPhysical.ToString).Copy
                    dtWorkName = DC_RackTables.tblAttrDiskPhysical.ToString
                    Exit Select

                Case "attresKey"
                    ' external storage
                    _clsReporting.initReports(_clsReporting.baseReports.rptDiskESAll)
                    dtWork = _clsData.m_ds.Tables(DC_RackTables.tblAttrExternalStorage.ToString).Copy
                    Exit Select

                Case "ndeDiskEsN"
                    ' external storage network attach view data
                    Exit Sub

                Case "attrnetKey"
                    ' component network
                    _clsReporting.initReports(_clsReporting.baseReports.rptAttrNetworkAll)
                    dtWork = _clsData.m_ds.Tables(DC_RackTables.tblAttrNetwork.ToString).Copy
                    dtWorkName = DC_RackTables.tblAttrNetwork.ToString
                    Exit Select

                Case "portKey"
                    ' component port data
                    _clsReporting.initReports(_clsReporting.baseReports.rptPortDataAll)
                    dtWork = _clsData.m_ds.Tables(DC_RackTables.tblAttrPortData.ToString).Copy
                    dtWorkName = DC_RackTables.tblAttrPortData.ToString
                    Exit Select

                Case Else

                    Exit Sub

            End Select


            ' let the system catch up
            System.Windows.Forms.Application.DoEvents()

            If dtWork Is Nothing Then
                MsgBox(strNode & " dtWork is nothing")
                Exit Sub
            End If
            If dtWork.Rows.Count < 1 Then
                MsgBox(strNode & " dtWork is empty")
                Exit Sub
            End If


            _clsReporting._DataTable = dtWork.Copy
            _clsReporting._DataTable.TableName = dtWorkName
            _clsReporting.createLocalReport()
            _clsReporting._LocalViewer.Refresh()
            _clsReporting._LocalViewer.RefreshReport()


        Catch sql As SqlException
            '********* visio snippet vb.net vis0057vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

        dtWork = Nothing


    End Sub

    '
    ' load visio document
    '
    Private Sub LoadToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LoadToolStripMenuItem.Click

        openVisioDocumentDialog()

    End Sub

    '
    ' save the visio document
    '
    Private Sub SaveToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click

        saveVisioDocumentDialog()

    End Sub

    '
    ' about dialog
    '
    Private Sub AboutToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click

        Dim frmAbout As frmAboutBox = New frmAboutBox
        frmAbout.ShowDialog()
        frmAbout.Dispose()
        frmAbout = Nothing


    End Sub

    '
    ' draw components attributes
    '
    Private Sub DrawDataToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DrawDataToolStripMenuItem.Click


        drawComponentAttributeData()

        Me.sblStatusOne.Text = "Draw Complete"
        Me.sblStatusTwo.Text = ""

        ' make sure the reporting class has been built in case the user
        ' selects a shape
        If _clsReporting Is Nothing Then
            Dim dtTemp As System.Data.DataTable = _clsData.m_ds.Tables(DC_RackTables.tblComponents.ToString).Copy
            ' load the component report
            _clsReporting = New visRackComponentAttributes.clsDC_RackReporting _
                    (Me.attributesReportViewer, _
                    _clsReporting.baseReports.rptComponentsAll, _
                    dtTemp)
            _clsReporting._LocalViewer.RefreshReport()
        End If



    End Sub


#End Region

#Region " draw attribute methods "


    '
    ' go through the data and add containers/lists to the drawing page
    '
    Private Sub drawComponentAttributeData()

        ' load our test data
        Me.Cursor = Cursors.WaitCursor

        Try

            Me.sblStatusOne.Text = "AttrDrawing"
            _clsVisio.drawingPage = drawingPage

            ' load the datagraphics information
            loadDGM()
            ' load the components
            loadComponent(Me.compKey)

            Dim shpComp As Microsoft.Office.Interop.Visio.Shape = drawingPage.Shapes("contComponent")
            If shpComp IsNot Nothing Then
                _clsVisio.SetCellValueToString(shpComp.Cells("pinX"), "1.5in")
                _clsVisio.SetCellValueToString(shpComp.Cells("pinY"), "6.75 in")
                System.Windows.Forms.Application.DoEvents()
            End If

            buildSoftwareContainer()
            Dim shpSoftware As Microsoft.Office.Interop.Visio.Shape = Nothing
            Try
                shpSoftware = drawingPage.Shapes("contSoftwareData")
            Catch
            End Try
            If shpSoftware IsNot Nothing Then
                _clsVisio.SetCellValueToString(shpSoftware.Cells("pinX"), "1.5in")
                _clsVisio.SetCellValueToString(shpSoftware.Cells("pinY"), "3.125 in")
            End If


            buildDiskContainer()
            Dim shpDisks As Microsoft.Office.Interop.Visio.Shape = Nothing
            Try
                shpDisks = drawingPage.Shapes("contDiskStorage")
            Catch
            End Try
            If shpDisks IsNot Nothing Then
                _clsVisio.SetCellValueToString(shpDisks.Cells("pinX"), "4.5 in")
                _clsVisio.SetCellValueToString(shpDisks.Cells("pinY"), "5.5 in")
            End If

            buildNetworkContainer()
            Dim shpNet As Microsoft.Office.Interop.Visio.Shape = Nothing
            Try
                shpNet = drawingPage.Shapes("contNetworkData")
            Catch
            End Try

            If shpNet IsNot Nothing Then
                _clsVisio.SetCellValueToString(shpNet.Cells("pinX"), "7 in")
                _clsVisio.SetCellValueToString(shpNet.Cells("pinY"), "8.5 in")
            End If


            ' paste the legend last
            Dim shpLegend As Microsoft.Office.Interop.Visio.Shape = PutOnLegend()
            _clsVisio.SetCellValueToString(shpLegend.Cells("pinX"), "1.5 in")
            _clsVisio.SetCellValueToString(shpLegend.Cells("pinY"), "10.375 in")

        Catch com As COMException
            '********* visio snippet vb.net vis0056vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

        Me.Cursor = Cursors.Default
        drawingWindow.DeselectAll()

    End Sub



    ' add the ability to fire marker event on shape doubleclick
    'Dim intDblClick As dc_Component.DC_RackCommand = dc_Component.DC_RackCommand.ShapeDoubleClick
    'Dim strRunAddon = "RUNADDONWARGS(""QueueMarkerEvent"", ""/dc_rack_attr /cmd=" & intDblClick & """)"
    '                    If visShape.CellExists("eventdblclick", VisExistsFlags.visExistsAnywhere) = True Then
    '                        visCell = visShape.Cells("eventdblclick")
    '                        _clsVisio.SetCellValueToString(visCell, strRunAddon)
    '                    End If


    '
    ' load the datagraphics masters table and preload the document with the shapes and
    ' predefined datagraphics
    '
    Private Sub loadDGM()

        ' be consistent in how we apply the data graphics
        Dim _clsDGM As visRackComponentAttributes.clsDgMasters = New visRackComponentAttributes.clsDgMasters

        Try

            Me.sblStatusTwo.Text = "DGMs Started"

            _clsDGM.drawingApplication = drawingApplication
            _clsDGM.drawingDocument = drawingDocument
            _clsDGM._StencilPath = _CustomStencilPath

            ' load the table
            If blnExcelSource = False Then
                _clsDGM.dbSelectAllDGMasters()
                _clsDGM.preLoadDocumentStencil()
                ' finally save the datagraphics master data to the working dataset
                _clsData.loadDgMasterTable(_clsDGM.m_ds.Tables(DC_RackTables.tblDGMasters.ToString).Copy)
            Else
                _clsDGM.m_dt = _clsData.m_ds.Tables(DC_RackTables.tblDGMasters.ToString).Copy
                _clsDGM.preLoadDocumentStencil()
            End If

            Me.sblStatusTwo.Text = "DGMs Loaded"

        Catch com As COMException
            '********* visio snippet vb.net vis0056vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If
        Catch sql As SqlException
            '********* visio snippet vb.net vis0057vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If

        Finally

            _clsDGM = Nothing

        End Try

    End Sub



    '
    ' based on the component key, read the component record from the data source
    '
    Public Sub loadComponent(ByVal intCompKey As Int32)

        Dim _clsComp As visRackComponentAttributes.clsComponents = New visRackComponentAttributes.clsComponents(drawingApplication, drawingDocument)

        Dim shpContainer As Microsoft.Office.Interop.Visio.Shape = Nothing

        Try

            Me.sblStatusTwo.Text = "Component Started"

            _clsComp.drawingPage = drawingPage

            If blnExcelSource = False Then
                _clsComp.dbSelectComponentByCompKey(intCompKey)
                _clsData.loadComponents(-1, Nothing, _clsComp.m_ds.Tables(DC_RackTables.tblComponents.ToString))
            End If

            shpContainer = _clsComp.buildComponentContainer(intCompKey, _clsData)
            shpContainer.Name = "contComponent"
            shpContainer.NameU = "contComponent"
            shpContainer.Text = "Component"

            Dim colInput As Collection = New Collection
            Dim componentQuery = From component In _clsData.m_ds.Tables(DC_RackTables.tblComponents.ToString).AsEnumerable() _
                       Where component!compkey = intCompKey
                      Select component

            Dim drTemp As System.Data.DataRow = Nothing
            ' we should only have transferred in a single component key
            If componentQuery.Count = 1 Then
                For Each c In componentQuery
                    Me.lblCompName.Text = c.Item("compName")
                    Me.lblCompLabel.Text = c.Item("compLabel")
                Next c
            End If

            Me.sblStatusTwo.Text = "Component Loaded"

        Catch com As COMException
            '********* visio snippet vb.net vis0056vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If
        Catch sql As SqlException
            '********* visio snippet vb.net vis0057vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If

        Finally

            _clsComp = Nothing

        End Try


    End Sub


    '***********************************************************************************
    ' software container
    '***********************************************************************************
    '
    '
    '
    Private Sub buildSoftwareContainer()

        Try

            Dim shpGroup As Microsoft.Office.Interop.Visio.Shape = Nothing
            Dim colInput As Collection = New Collection
            ' processor and software
            shpGroup = loadProcessor()
            If shpGroup IsNot Nothing Then
                colInput.Add(shpGroup.ID)
                shpGroup = Nothing
            End If
            shpGroup = loadOperatingSystem()
            If shpGroup IsNot Nothing Then
                colInput.Add(shpGroup.ID)
                shpGroup = Nothing
            Else
                GoTo EndApps
            End If
            shpGroup = loadApplications()
            If shpGroup IsNot Nothing Then
                colInput.Add(shpGroup.ID)
                shpGroup = Nothing
            End If
            shpGroup = loadVirtualHosts()
            If shpGroup IsNot Nothing Then
                colInput.Add(shpGroup.ID)
                shpGroup = Nothing
            End If
EndApps:
            If colInput.Count = 0 Then Exit Sub

            Dim shpContainer As Microsoft.Office.Interop.Visio.Shape = Nothing
            shpContainer = _clsVisio.addContainerToPage("Container 4", "contSoftwareData", "Software Data")
            ' create a list control
            Dim listControl As Microsoft.Office.Interop.Visio.Shape = Nothing
            listControl = _clsVisio.loadListControl(colInput, _
                                              VisListAlignment.visListAlignLeftOrTop, _
                                              VisListDirection.visListDirTopToBottom)
            ' add the list control to the container
            _clsVisio.AddShapeToContainer(shpContainer, listControl)

        Catch com As COMException
            '********* visio snippet vb.net vis0056vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If

        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try
    End Sub
    '
    ' based on the component key, read the processor record from the data source
    '
    Private Function loadProcessor() As Microsoft.Office.Interop.Visio.Shape

        Dim _clsProc As visRackComponentAttributes.clsAttrProcessor = New visRackComponentAttributes.clsAttrProcessor(drawingApplication, drawingDocument)
        Dim shpContainer As Microsoft.Office.Interop.Visio.Shape = Nothing

        Try

            Me.sblStatusTwo.Text = "Processor Loading"

            _clsProc.drawingPage = drawingPage
            _clsProc._CustomStencilPath = _CustomStencilPath

            If blnExcelSource = False Then
                _clsProc.dbSelectAttrProcessorByCompKey(Me.compKey)
                _clsData.loadProcessorTable(_clsProc.m_ds.Tables(clsDC_RackData.DC_RackTables.tblAttrProcessor.ToString))
            End If

            shpContainer = _clsProc.buildComponentProcessorContainer(Me.compKey, _clsData)

            'Dim rdProcessor As Microsoft.Office.Interop.Visio.DataRecordset = Nothing
            'rdProcessor = _clsData._ProcessorRd

            Me.sblStatusTwo.Text = "Processor Loaded"


        Catch com As COMException
            '********* visio snippet vb.net vis0056vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If
        Catch sql As SqlException
            '********* visio snippet vb.net vis0057vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If

        Finally

            _clsProc = Nothing

        End Try

        Return shpContainer

    End Function
    '
    ' based on the component key, read the operating system record from the data source
    '
    Private Function loadOperatingSystem() As Microsoft.Office.Interop.Visio.Shape

        Dim _clsOS As visRackComponentAttributes.clsAttrOperatingSystem = _
            New visRackComponentAttributes.clsAttrOperatingSystem(drawingApplication, drawingDocument)

        Dim shpContainer As Microsoft.Office.Interop.Visio.Shape = Nothing

        Try

            Me.sblStatusTwo.Text = "OpSys Loading"

            _clsOS.drawingPage = drawingPage
            _clsOS._CustomStencilPath = _CustomStencilPath

            If blnExcelSource = False Then
                _clsOS.dbSelectAttrOperatingSystemByCompKey(Me.compKey)
                ' save it over in the data class
                _clsData.loadAttrOperatingSystems(-1, Nothing, _clsOS.m_ds.Tables(clsDC_RackData.DC_RackTables.tblAttrOperatingSystem.ToString))
            End If

            shpContainer = _clsOS.buildComponentOperatingSystemContainer(Me.compKey, _clsData)

            'Dim rdOS As Microsoft.Office.Interop.Visio.DataRecordset = Nothing
            'rdOS = _clsData._AttrOSRd

            Me.sblStatusTwo.Text = "OpSys Loaded"


        Catch com As COMException
            '********* visio snippet vb.net vis0056vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If
        Catch sql As SqlException
            '********* visio snippet vb.net vis0057vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If

        Finally

            _clsOS = Nothing

        End Try

        Return shpContainer

    End Function
    '
    ' based on the operating system key, read the virtual host records from the data source
    '
    Private Function loadVirtualHosts() As Microsoft.Office.Interop.Visio.Shape

        Dim _clsVH As visRackComponentAttributes.clsAttrVirtualHost = New visRackComponentAttributes.clsAttrVirtualHost(drawingApplication, drawingDocument)

        Dim shpContainer As Microsoft.Office.Interop.Visio.Shape = Nothing

        Try

            Dim intSystem As Int32 = -1

            Me.sblStatusTwo.Text = "VirtHost Loading"


            Dim operatingsystemQuery = From operatingsystem In _clsData.m_ds.Tables(DC_RackTables.tblAttrOperatingSystem.ToString).AsEnumerable() _
                Where operatingsystem!oscompkey = Me.compKey
                Select operatingsystem

            ' should only be a single operating system 
            If operatingsystemQuery.Count = 1 Then
                For Each o In operatingsystemQuery
                    intSystem = o.Item("osKey")
                Next o
            End If

            ' if no operating system then get out
            If intSystem < 0 Then
                _clsVH = Nothing
                Return shpContainer
            End If

            _clsVH.drawingPage = drawingPage
            _clsVH._CustomStencilPath = _CustomStencilPath


            If blnExcelSource = False Then
                ' find our operating system record
                _clsVH.dbSelectVirtualHostBySystemKey(intSystem)
                ' save it over in the data class
                _clsData.loadAttrVirtualHosts(-1, Nothing, _clsVH.m_ds.Tables(clsDC_RackData.DC_RackTables.tblAttrVirtualHost.ToString))
            End If

            shpContainer = _clsVH.buildSystemVirtualHostContainer(intSystem, _clsData)


            'Dim rdVH As Microsoft.Office.Interop.Visio.DataRecordset = Nothing
            'rdVH = _clsData._AttrVHRd

            Me.sblStatusTwo.Text = "Virt Loaded"


        Catch com As COMException
            '********* visio snippet vb.net vis0056vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If
        Catch sql As SqlException
            '********* visio snippet vb.net vis0057vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If

        Finally

            _clsVH = Nothing

        End Try

        Return shpContainer

    End Function
    '
    ' based on the operating system key, read the application records from the data source
    '
    Private Function loadApplications() As Microsoft.Office.Interop.Visio.Shape

        Dim _clsApp As visRackComponentAttributes.clsAttrApplications = New visRackComponentAttributes.clsAttrApplications(drawingApplication, drawingDocument)

        Dim shpContainer As Microsoft.Office.Interop.Visio.Shape = Nothing

        Try

            Dim intSystem As Int32 = -1

            Me.sblStatusTwo.Text = "Apps Loading"


            Dim operatingsystemQuery = From operatingsystem In _clsData.m_ds.Tables(DC_RackTables.tblAttrOperatingSystem.ToString).AsEnumerable() _
                Where operatingsystem!oscompkey = Me.compKey
                Select operatingsystem

            ' should only be a single operating system 
            If operatingsystemQuery.Count = 1 Then
                For Each o In operatingsystemQuery
                    intSystem = o.Item("osKey")
                Next o
            End If

            If intSystem < 0 Then
                _clsApp = Nothing
                Return shpContainer
            End If

            _clsApp.drawingPage = drawingPage
            _clsApp._CustomStencilPath = _CustomStencilPath

            If blnExcelSource = False Then
                ' find our operating system record
                _clsApp.dbSelectAttrApplicationsBySystemKey(intSystem)
                _clsData.loadAppTable(_clsApp.m_ds.Tables(clsDC_RackData.DC_RackTables.tblAttrApplication.ToString))
            End If

            shpContainer = _clsApp.buildSystemApplicationContainer(intSystem, _clsData)


            'Dim rdApps As Microsoft.Office.Interop.Visio.DataRecordset = Nothing
            'rdApps = _clsData._AppRd


            Me.sblStatusTwo.Text = "Apps Loaded"


        Catch com As COMException
            '********* visio snippet vb.net vis0056vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If
        Catch sql As SqlException
            '********* visio snippet vb.net vis0057vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If

        Finally

            _clsApp = Nothing

        End Try

        Return shpContainer

    End Function


    '***********************************************************************************
    ' disk container
    '***********************************************************************************
    '
    '
    '
    Private Sub buildDiskContainer()
        Try

            Dim shpGroup As Microsoft.Office.Interop.Visio.Shape = Nothing
            Dim colInput As Collection = New Collection
            ' the disk stuff
            shpGroup = loadDiskPhysical()
            If shpGroup IsNot Nothing Then
                colInput.Add(shpGroup.ID)
                shpGroup = Nothing
            End If
            shpGroup = loadDiskLogical()
            If shpGroup IsNot Nothing Then
                colInput.Add(shpGroup.ID)
                shpGroup = Nothing
            End If
            shpGroup = loadDiskES()
            If shpGroup IsNot Nothing Then
                colInput.Add(shpGroup.ID)
                shpGroup = Nothing
            End If


            If colInput.Count = 0 Then Exit Sub

            Dim shpContainer As Microsoft.Office.Interop.Visio.Shape = Nothing
            shpContainer = _clsVisio.addContainerToPage("Container 4", "contDiskStorage", "Disk Storage")

            ' create a list control
            Dim listControl As Microsoft.Office.Interop.Visio.Shape = Nothing

            listControl = _clsVisio.loadListControl(colInput, _
                                              VisListAlignment.visListAlignLeftOrTop, _
                                              VisListDirection.visListDirTopToBottom)

            ' add the list control to the container
            _clsVisio.AddShapeToContainer(shpContainer, listControl)

        Catch com As COMException
            '********* visio snippet vb.net vis0056vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If

        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try
    End Sub
    '
    ' based on the component key, read the disk physical record(s) from the data source
    '
    Private Function loadDiskPhysical() As Microsoft.Office.Interop.Visio.Shape

        Dim _clsDiskP As visRackComponentAttributes.clsAttrDiskPhysical = New visRackComponentAttributes.clsAttrDiskPhysical(drawingApplication, drawingDocument)

        Dim shpContainer As Microsoft.Office.Interop.Visio.Shape = Nothing

        Try

            Me.sblStatusTwo.Text = "DiskPhys Loading"

            _clsDiskP.drawingPage = drawingPage
            _clsDiskP._CustomStencilPath = _CustomStencilPath

            If blnExcelSource = False Then
                _clsDiskP.dbSelectAttrDiskPhysicalByCompKey(Me.compKey)
                _clsData.loadAttrDiskPhysical(-1, Nothing, _clsDiskP.m_ds.Tables(clsDC_RackData.DC_RackTables.tblAttrDiskPhysical.ToString))
            End If

            shpContainer = _clsDiskP.buildComponentDiskPhysicalContainer(Me.compKey, _clsData)


            'Dim rdDiskPhysical As Microsoft.Office.Interop.Visio.DataRecordset = Nothing
            'rdDiskPhysical = _clsData._DiskPhysicalRd


            Me.sblStatusTwo.Text = "DiskPhys Loaded"


        Catch com As COMException
            '********* visio snippet vb.net vis0056vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If
        Catch sql As SqlException
            '********* visio snippet vb.net vis0057vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If

        Finally

            _clsDiskP = Nothing

        End Try

        Return shpContainer

    End Function

    '
    ' based on the component key, read the disk logical record(s) from the data source
    '
    Private Function loadDiskLogical() As Microsoft.Office.Interop.Visio.Shape

        Dim _clsDiskL As visRackComponentAttributes.clsAttrDiskLogical = New visRackComponentAttributes.clsAttrDiskLogical(drawingApplication, drawingDocument)
        Dim shpContainer As Microsoft.Office.Interop.Visio.Shape = Nothing

        Try

            Me.sblStatusTwo.Text = "DiskLog Loading"

            _clsDiskL.drawingPage = drawingPage
            _clsDiskL._CustomStencilPath = _CustomStencilPath

            If blnExcelSource = False Then
                _clsDiskL.dbSelectAttrDiskLogicalByCompKey(Me.compKey)
                _clsData.loadAttrDiskLogical(-1, Nothing, _clsDiskL.m_ds.Tables(clsDC_RackData.DC_RackTables.tblAttrDiskLogical.ToString))
            End If

            shpContainer = _clsDiskL.buildComponentDiskLogicalContainer(Me.compKey, _clsData)


            'Dim rdDiskLogical As Microsoft.Office.Interop.Visio.DataRecordset = Nothing
            'rdDiskLogical = _clsData._DiskLogicalRd

            ' add the container to hold the list


            Me.sblStatusTwo.Text = "DiskLog Loaded"


        Catch com As COMException
            '********* visio snippet vb.net vis0056vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If
        Catch sql As SqlException
            '********* visio snippet vb.net vis0057vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If

        Finally

            _clsDiskL = Nothing

        End Try

        Return shpContainer

    End Function
    '
    ' based on the component key, read the disk external storage record(s) from the data source
    '
    Private Function loadDiskES() As Microsoft.Office.Interop.Visio.Shape

        Dim _clsDiskES As visRackComponentAttributes.clsAttrDiskES = New visRackComponentAttributes.clsAttrDiskES(drawingApplication, drawingDocument)

        Dim shpContainer As Microsoft.Office.Interop.Visio.Shape = Nothing

        Try

            Me.sblStatusTwo.Text = "DiskExt Loading"

            _clsDiskES.drawingPage = drawingPage
            _clsDiskES._CustomStencilPath = _CustomStencilPath

            If blnExcelSource = False Then
                ' find our component record
                _clsDiskES.dbSelectAttrExternalStorageByCompKey(Me.compKey)
                _clsData.loadAttrExternalStorage(-1, Nothing, _clsDiskES.m_ds.Tables(clsDC_RackData.DC_RackTables.tblAttrExternalStorage.ToString))
            End If

            shpContainer = _clsDiskES.buildComponentDiskESContainer(Me.compKey, _clsData)

            'Dim rdExternal As Microsoft.Office.Interop.Visio.DataRecordset = Nothing
            'rdExternal = _clsData._AttrESRd


            Me.sblStatusTwo.Text = "DiskExt Loaded"


        Catch com As COMException
            '********* visio snippet vb.net vis0056vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If
        Catch sql As SqlException
            '********* visio snippet vb.net vis0057vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If

        Finally

            _clsDiskES = Nothing

        End Try

        Return shpContainer

    End Function


    '***********************************************************************************
    ' network container
    '***********************************************************************************

    '
    '
    '
    Private Sub buildNetworkContainer()
        Try

            Dim shpGroup As Microsoft.Office.Interop.Visio.Shape = Nothing
            Dim colInput As Collection = New Collection
            shpGroup = loadCompNet()
            If shpGroup IsNot Nothing Then
                colInput.Add(shpGroup.ID)
                shpGroup = Nothing
            End If
            shpGroup = loadCompPort()
            If shpGroup IsNot Nothing Then
                colInput.Add(shpGroup.ID)
                shpGroup = Nothing
            End If

            If colInput.Count = 0 Then Exit Sub

            Dim shpContainer As Microsoft.Office.Interop.Visio.Shape = Nothing
            shpContainer = _clsVisio.addContainerToPage("Container 4", "contNetworkData", "NetworkData")


            ' create a list control
            Dim listControl As Microsoft.Office.Interop.Visio.Shape = Nothing
            listControl = _clsVisio.loadListControl(colInput, _
                                              VisListAlignment.visListAlignLeftOrTop, _
                                              VisListDirection.visListDirTopToBottom)
            ' add the list control to the container
            _clsVisio.AddShapeToContainer(shpContainer, listControl)


        Catch com As COMException
            '********* visio snippet vb.net vis0056vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If

        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try
    End Sub

    '
    ' based on the component key, read the network record(s) from the data source
    '
    Private Function loadCompNet() As Microsoft.Office.Interop.Visio.Shape

        Dim _clsCompNet As visRackComponentAttributes.clsAttrNetwork = New visRackComponentAttributes.clsAttrNetwork(drawingApplication, drawingDocument)
        Dim shpContainer As Microsoft.Office.Interop.Visio.Shape = Nothing

        Try

            Me.sblStatusTwo.Text = "Net Loaded"


            _clsCompNet.drawingPage = drawingPage
            _clsCompNet._CustomStencilPath = _CustomStencilPath

            If blnExcelSource = False Then
                _clsCompNet.dbSelectAttrNetworkByCompKey(Me.compKey)
                _clsData.loadAttrNetwork(-1, Nothing, _clsCompNet.m_ds.Tables(clsDC_RackData.DC_RackTables.tblAttrNetwork.ToString))
            End If

            shpContainer = _clsCompNet.buildNetworkDataContainer("comp", Me.compKey, _clsData, vbTrue)



            'Dim rdNetwork As Microsoft.Office.Interop.Visio.DataRecordset = Nothing
            'rdNetwork = _clsData._AttrNetRd


            Me.sblStatusTwo.Text = "Net Loaded"


        Catch com As COMException
            '********* visio snippet vb.net vis0056vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If
        Catch sql As SqlException
            '********* visio snippet vb.net vis0057vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If

        Finally

            _clsCompNet = Nothing

        End Try

        Return shpContainer

    End Function

    '
    ' based on the component key, read the port record(s) from the data source
    '
    Private Function loadCompPort() As Microsoft.Office.Interop.Visio.Shape

        Dim _clsCompPort As visRackComponentAttributes.clsAttrPortData = New visRackComponentAttributes.clsAttrPortData(drawingApplication, drawingDocument)
        Dim shpContainer As Microsoft.Office.Interop.Visio.Shape = Nothing

        Try


            Me.sblStatusTwo.Text = "Port Started"



            _clsCompPort.drawingPage = drawingPage
            _clsCompPort._CustomStencilPath = _CustomStencilPath

            If blnExcelSource = False Then

                _clsCompPort.dbSelectAttrPortDataByCompKey(Me.compKey)
                _clsData.loadAttrPortData(-1, Nothing, _clsCompPort.m_ds.Tables(clsDC_RackData.DC_RackTables.tblAttrPortData.ToString))

            End If

            shpContainer = _clsCompPort.buildPortDataContainer("comp", Me.compKey, _clsData)

            'Dim rdPortData As Microsoft.Office.Interop.Visio.DataRecordset = Nothing
            'rdPortData = _clsData._PortRd


            Me.sblStatusTwo.Text = "Port Loaded"


        Catch com As COMException
            '********* visio snippet vb.net vis0056vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If
        Catch sql As SqlException
            '********* visio snippet vb.net vis0057vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(sql, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If

        Finally

            _clsCompPort = Nothing

        End Try

        Return shpContainer

    End Function


    '
    '
    '
    Private Function PutOnLegend() As Microsoft.Office.Interop.Visio.Shape

        Dim vsoShape As Microsoft.Office.Interop.Visio.Shape = Nothing

        Try

            Dim docStencil As Microsoft.Office.Interop.Visio.Document
            Dim strStencilName As String = "periph_u.vss"
            Dim strMaster As String = "Legend"


            Dim vsoPage As Microsoft.Office.Interop.Visio.Page = drawingPage

            vsoShape = _clsVisio.DropMasterOnPage(vsoPage, strMaster, strStencilName, 24, 24, VisUnitCodes.visInches)
            vsoShape.Name = "visLegend"
            vsoShape.NameU = "visLegend"
            vsoShape.Cells("PinX").Formula = "1in"
            vsoShape.Cells("PinY").Formula = "2in"

            ' since it has to be open, close it
            docStencil = drawingApplication.Documents(strStencilName)
            docStencil.Close()
            docStencil = Nothing

        Catch com As COMException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If
        Catch err As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(err, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If

        End Try

        Return vsoShape

    End Function



#End Region

#Region " External get/save "

    ' dictTables is a list of the tables we will use in this solution
    ' enumTable value and the exported table name
    Private dictTables As Dictionary(Of Int16, String)

    '
    ' used to load test case data from excel source
    '
    Private Sub loadExcelTestData()

        Try

            Me.sblStatusOne.Text = "Initializing"

            Dim dtTemp As System.Data.DataTable = Nothing
            Dim dictTemp As Dictionary(Of Int16, String) = New Dictionary(Of Int16, String)

            ' read the worksheet list into a local dictionary
            dictTemp = readExcelWorksheetList(My.Settings.path_custom_data & My.Settings.workbook_custom_data)
            Dim blnContains As Boolean = True
            ' are there enough worksheets
            If dictTables.Count <= dictTemp.Count Then
                For Each kvp In dictTables
                    If dictTemp.ContainsValue(kvp.Value) = False Then
                        blnContains = False
                    End If
                Next kvp
            Else
                MsgBox("Not enough worksheets for this solutions")
                Exit Sub
            End If

            If blnContains = False Then
                MsgBox("Could not find all necessary worksheets")
                Exit Sub
            End If

            ' now read the worksheets into the tables
            ' the keyvalue pairs are the table index, and the modified table name
            For Each kvp In dictTables
                dtTemp = Nothing
                dtTemp = readExcelWorksheet(My.Settings.path_custom_data & My.Settings.workbook_custom_data, kvp.Value)
                If dtTemp Is Nothing Then GoTo NextKvp
                dtTemp.TableName = CType(kvp.Key, DC_RackTables).ToString

                Select Case kvp.Key
                    Case DC_RackTables.tblComponents
                        Me.sblStatusTwo.Text = DC_RackTables.tblComponents.ToString & " loading "
                        _clsData.loadComponents(-1, Nothing, dtTemp)
                    Case DC_RackTables.tblDGMasters
                        Me.sblStatusTwo.Text = DC_RackTables.tblDGMasters.ToString & " loading "
                        _clsData.loadDgMasterTable(dtTemp)
                    Case DC_RackTables.tblAttrApplication
                        Me.sblStatusTwo.Text = DC_RackTables.tblAttrApplication.ToString & " loading "
                        _clsData.loadAppTable(dtTemp)
                    Case DC_RackTables.tblAttrOperatingSystem
                        Me.sblStatusTwo.Text = DC_RackTables.tblAttrOperatingSystem.ToString & " loading "
                        _clsData.loadAttrOperatingSystems(-1, Nothing, dtTemp)
                    Case DC_RackTables.tblAttrVirtualHost
                        Me.sblStatusTwo.Text = DC_RackTables.tblAttrVirtualHost.ToString & " loading "
                        _clsData.loadAttrVirtualHosts(-1, Nothing, dtTemp)
                    Case DC_RackTables.tblAttrProcessor
                        Me.sblStatusTwo.Text = DC_RackTables.tblAttrProcessor.ToString & " loading "
                        _clsData.loadProcessorTable(dtTemp)
                    Case DC_RackTables.tblAttrDiskPhysical
                        Me.sblStatusTwo.Text = DC_RackTables.tblAttrDiskPhysical.ToString & " loading "
                        _clsData.loadAttrDiskPhysical(-1, Nothing, dtTemp)
                    Case DC_RackTables.tblAttrDiskLogical
                        Me.sblStatusTwo.Text = DC_RackTables.tblAttrDiskLogical.ToString & " loading "
                        _clsData.loadAttrDiskLogical(-1, Nothing, dtTemp)
                    Case DC_RackTables.tblAttrExternalStorage
                        Me.sblStatusTwo.Text = DC_RackTables.tblAttrExternalStorage.ToString & " loading "
                        _clsData.loadAttrExternalStorage(-1, Nothing, dtTemp)
                    Case DC_RackTables.tblAttrPortData
                        Me.sblStatusTwo.Text = DC_RackTables.tblAttrPortData.ToString & " loading "
                        _clsData.loadAttrPortData(-1, Nothing, dtTemp)
                    Case DC_RackTables.tblAttrNetwork
                        Me.sblStatusTwo.Text = DC_RackTables.tblAttrNetwork.ToString & " loading "
                        _clsData.loadAttrNetwork(-1, Nothing, dtTemp)
                End Select
NextKvp:
            Next kvp

            Me.sblStatusOne.Text = "DataLoaded"
            Me.sblStatusTwo.Text = _clsData.m_ds.Tables.Count.ToString & " tables loaded"

        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub

    '
    ' create the list of tables that we will need for this visio report
    ' this is pretty much all of the defined attributes for a rack mounted
    ' component
    '
    Private Sub loadTestDictTables()


        dictTables = Nothing
        dictTables = New Dictionary(Of Int16, String)

        ' the basics
        dictTables.Add(DC_RackTables.tblComponents, "dbo_tblComponents")
        dictTables.Add(DC_RackTables.tblDGMasters, "dbo_tblDGMasters")
        ' first some software views
        dictTables.Add(DC_RackTables.tblAttrProcessor, "dbo_tblAttrProcessor")
        dictTables.Add(DC_RackTables.tblAttrApplication, "dbo_tblAttrApplications")
        dictTables.Add(DC_RackTables.tblAttrOperatingSystem, "dbo_tblAttrOperatingSystem")
        dictTables.Add(DC_RackTables.tblAttrVirtualHost, "dbo_tblAttrVirtualHost")
        ' then some disk storage views
        dictTables.Add(DC_RackTables.tblAttrDiskPhysical, "dbo_tblAttrDiskPhysical")
        dictTables.Add(DC_RackTables.tblAttrDiskLogical, "dbo_tblAttrDiskLogical")
        dictTables.Add(DC_RackTables.tblAttrExternalStorage, "dbo_tblAttrExternalStorage")
        ' initial network data
        dictTables.Add(DC_RackTables.tblAttrNetwork, "dbo_tblAttrNetwork")
        dictTables.Add(DC_RackTables.tblAttrPortData, "dbo_tblAttrPortData")


    End Sub

    '
    ' Reads a workbook and returns a collection of worksheet names as a 
    ' dictionary
    '
    Private Function readExcelWorksheetList _
        (ByVal strWorkbook As String) _
        As Dictionary(Of Int16, String)

        Dim dictReturn As Dictionary(Of Int16, String) = New Dictionary(Of Int16, String)
        Dim objExcel As Microsoft.Office.Interop.Excel.Application = Nothing
        Dim objWorkBook As Microsoft.Office.Interop.Excel.Workbook = Nothing
        Dim objWorkSheets As Microsoft.Office.Interop.Excel.Worksheet = Nothing

        Try

            If (strWorkbook Is Nothing) Then
                Throw New System.ArgumentNullException("strWorkbookValueIsNull", _
                    "Workbook is Null.")
                GoTo ExitFunction
            End If

            If File.Exists(strWorkbook) = False Then
                MsgBox("Workbook (" & strWorkbook & ") not found")
                GoTo ExitFunction
            End If

            Dim ExcelSheetName As String = ""
            objExcel = CreateObject("Excel.Application")
            objWorkBook = objExcel.Workbooks.Open(strWorkbook)
            Dim intX As Integer = 1
            For Each objWorkSheets In objWorkBook.Worksheets
                dictReturn.Add(intX, objWorkSheets.Name)
                intX = intX + 1
            Next

ExitFunction:

        Catch com As COMException
            '********* visio snippet vb.net vis0056vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If

        Catch ex As Exception
            '********* visio snippet vb.net vis0059vb ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If

        Finally

            objWorkSheets = Nothing
            objWorkBook = Nothing
            objExcel.Quit()
            objExcel = Nothing

        End Try

        Return dictReturn

    End Function

    '
    ' read a worksheet and return a datatable
    '
    Private Function readExcelWorksheet _
            (ByVal strWorkBook As String, _
            ByVal strWorkSheet As String) _
            As System.Data.DataTable


        Dim dtReturn As System.Data.DataTable = Nothing

        Try

            If (strWorkBook Is Nothing) _
                Or strWorkBook = "" Then
                Throw New System.ArgumentNullException("strWorkbookValueIsNull", _
                    "Workbook is Null.")
                GoTo ExitFunction
            End If

            If File.Exists(strWorkBook) = False Then
                MsgBox("Workbook (" & strWorkBook & ") not found")
                GoTo ExitFunction
            End If

            Dim DS As DataSet
            Dim MyCommand As OleDb.OleDbDataAdapter
            Dim MyConnection As OleDb.OleDbConnection
            Dim strConnection As String = "Provider=Microsoft.ACE.OLEDB.12.0;" _
                                          & "Data Source=" & strWorkBook & ";" _
                                          & "Extended Properties=" & """Excel 12.0 Xml;HDR=YES""" & ";"
            MyConnection = New OleDb.OleDbConnection(strConnection)
            MyCommand = New OleDb.OleDbDataAdapter( _
                         "select * from [" & strWorkSheet & "$]", MyConnection)
            DS = New System.Data.DataSet()
            MyCommand.Fill(DS)
            dtReturn = DS.Tables(0)
            dtReturn.TableName = strWorkSheet
            MyConnection.Close()

ExitFunction:

        Catch oledb As OleDbException
            '********* visio snippet vb.net visXXXX ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(oledb, "Database Policy")
            If (rethrow) Then
                Throw
            End If
        Catch ex As Exception
            '********* visio snippet vb.net visXXXX ******************
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

        Return dtReturn

    End Function

    '
    ' 
    '
    Private Sub saveVisioDocumentDialog()



        Try

            Dim visDoc As Microsoft.Office.Interop.Visio.Document = Me.drawingDocument

            ' flag the document as one of ours
            Dim docsheet As Microsoft.Office.Interop.Visio.Shape = visDoc.DocumentSheet
            _clsVisio.ForceUserProperty(docsheet, "Solution", "DC_Rack")
            _clsVisio.ForceUserProperty(docsheet, "Diagram", "CompAttributes")

            SaveFileDialog.Filter = "vsd files (*.vsd)|*.vsd|All files (*.*)|*.*"
            SaveFileDialog.FilterIndex = 1
            SaveFileDialog.RestoreDirectory = True

            Dim dlgResult As DialogResult = SaveFileDialog.ShowDialog

            If dlgResult = DialogResult.OK Then
                If _clsData._BlnDR = vbTrue Then
                    Dim resultMsg As MsgBoxResult = MsgBox("Save Hidden Data?", MsgBoxStyle.YesNo, "SaveHiddenData")
                    If resultMsg = MsgBoxResult.No Then
                        ' get rid of recordsets, masters, and personal information
                        visDoc.RemoveHiddenInformation(Microsoft.Office.Interop.Visio.VisRemoveHiddenInfoItems.visRHIDataRecordsets + _
                                                       Microsoft.Office.Interop.Visio.VisRemoveHiddenInfoItems.visRHIMasters + _
                                                       Microsoft.Office.Interop.Visio.VisRemoveHiddenInfoItems.visRHIPersonalInfo)
                    Else

                        Dim resultMsgLink As MsgBoxResult = MsgBox("Try to link records before save?", MsgBoxStyle.YesNo, "Attempt to Link Records")
                        If resultMsgLink = MsgBoxResult.Yes Then
                            attemptLinkRecords()
                        End If
                    End If

                End If


                visDoc.SaveAsEx(SaveFileDialog.FileName, Microsoft.Office.Interop.Visio.tagVisOpenSaveArgs.visSaveAsWS + _
                                Microsoft.Office.Interop.Visio.tagVisOpenSaveArgs.visSaveAsListInMRU)

            Else

                MsgBox("Save Cancelled")

            End If

        Catch com As COMException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If
        Catch err As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(err, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try


        System.GC.Collect()

    End Sub


    '
    '
    '
    Private Sub attemptLinkRecords()

        Try

            Dim visShapes As Microsoft.Office.Interop.Visio.Shapes = drawingPage.Shapes
            Dim visShape As Microsoft.Office.Interop.Visio.Shape
            Dim strShapeKey As String = ""
            Dim charSeparators() As Char = {"_"c}
            Dim count As Integer = 2
            Dim options As StringSplitOptions = StringSplitOptions.None
            Dim returnValue As String()
            Dim strTable As String = ""
            Dim strKey As String = ""
            Dim strFilter As String = ""
            Dim lngRowIds() As Int32
            Dim visRecordset As Microsoft.Office.Interop.Visio.DataRecordset = Nothing
            For Each visShape In visShapes
                strFilter = ""
                lngRowIds = {}
                strKey = ""
                visRecordset = Nothing
                ' was the attribute key saved
                If visShape.CellExists("user.attrkey", False) = True Then

                    strShapeKey = visShape.Cells("user.attrkey").ResultStr("")
                    returnValue = strShapeKey.Split(charSeparators, _
                            count, options)
                    strKey = LCase(returnValue(0))
                    Select Case strKey

                        Case "compkey"
                            strTable = clsDC_RackData.DC_RackTables.tblComponents.ToString
                            strFilter = "compKey ='" & CInt(returnValue(1)) & "'"
                            visRecordset = _clsData._CompRd
                            Exit Select
                        Case "appkey"
                            strTable = clsDC_RackData.DC_RackTables.tblAttrApplication.ToString
                            strFilter = "appKey ='" & CInt(returnValue(1)) & "'"
                            visRecordset = _clsData._AppRd
                            Exit Select
                        Case "physprockey"
                            strTable = clsDC_RackData.DC_RackTables.tblAttrProcessor.ToString
                            strFilter = "physProcKey ='" & CInt(returnValue(1)) & "'"
                            visRecordset = _clsData._ProcessorRd
                            Exit Select
                        Case "oskey"
                            strTable = clsDC_RackData.DC_RackTables.tblAttrOperatingSystem.ToString
                            strFilter = "osKey ='" & CInt(returnValue(1)) & "'"
                            visRecordset = _clsData._AttrOSRd
                            Exit Select
                        Case "vhkey"
                            strTable = clsDC_RackData.DC_RackTables.tblAttrVirtualHost.ToString
                            strFilter = "vhKey ='" & CInt(returnValue(1)) & "'"
                            visRecordset = _clsData._AttrVHRd
                            Exit Select
                        Case "logicaldiskkey"
                            strTable = clsDC_RackData.DC_RackTables.tblAttrDiskLogical.ToString
                            strFilter = "logicalDiskKey ='" & CInt(returnValue(1)) & "'"
                            visRecordset = _clsData._DiskLogicalRd
                            Exit Select
                        Case "physdiskkey"
                            strTable = clsDC_RackData.DC_RackTables.tblAttrDiskPhysical.ToString
                            strFilter = "physDiskKey ='" & CInt(returnValue(1)) & "'"
                            visRecordset = _clsData._DiskPhysicalRd
                            Exit Select
                        Case "attreskey"
                            strTable = clsDC_RackData.DC_RackTables.tblAttrExternalStorage.ToString
                            strFilter = "attresKey ='" & CInt(returnValue(1)) & "'"
                            visRecordset = _clsData._AttrESRd
                            Exit Select
                        Case "portkey"
                            strTable = clsDC_RackData.DC_RackTables.tblAttrPortData.ToString
                            strFilter = "portKey ='" & CInt(returnValue(1)) & "'"
                            visRecordset = _clsData._PortRd
                            Exit Select
                        Case "attrnetkey"
                            strTable = clsDC_RackData.DC_RackTables.tblAttrNetwork.ToString
                            strFilter = "attrnetKey ='" & CInt(returnValue(1)) & "'"
                            visRecordset = _clsData._AttrNetRd
                            Exit Select
                        Case Else
                            GoTo NextShape

                    End Select

                    If visRecordset IsNot Nothing Then
                        lngRowIds = visRecordset.GetDataRowIDs(strFilter)
                        If lngRowIds.Count = 1 Then
                            visShape.LinkToData(visRecordset.ID, lngRowIds(0), vbFalse)
                        End If ' test to make sure we found the record with the key
                    End If ' make sure it is not an empty recordset

                End If ' test to ensure it has an attribute key
NextShape:
            Next ' next shape on the page


        Catch com As COMException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If
        Catch err As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(err, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub

    '
    '
    '
    Private Sub openVisioDocumentDialog()



        Try

            OpenFileDialog.InitialDirectory = "c:\"
            OpenFileDialog.FileName = "*.vsd"
            OpenFileDialog.Filter = "visio drawings (*.vsd)|*.vsd|All files (*.*)|*.*"
            OpenFileDialog.FilterIndex = 1
            OpenFileDialog.RestoreDirectory = True

            Dim strPath As String = ""
            Dim dlgResult As System.Windows.Forms.DialogResult = OpenFileDialog.ShowDialog

            If dlgResult = System.Windows.Forms.DialogResult.OK Then

                Me.drawingControl.Src = OpenFileDialog.FileName

                Me.drawingWindow = Me.drawingControl.Window
                Me.drawingApplication = Me.drawingControl.Window.Application
                Me.drawingDocument = Me.drawingApplication.ActiveDocument
                Me.drawingPage = Me.drawingApplication.ActivePage

                ' flag it as already having been saved
                Me.drawingDocument.Saved = True

            End If

        Catch com As COMException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(com, "Com+ Policy")
            If (rethrow) Then
                Throw
            End If
        Catch err As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(err, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub

#End Region












End Class